package com.kh.statistics.video.base;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang.StringUtils;
import org.mapstruct.Named;

/**
 * @BelongsProject: statistics
 * @BelongsPackage: com.kh.statistics.video.base
 * @Author: Hong.Kong
 * @CreateTime: 2024-06-17  15:57
 * @Description: TODO
 * @Version: 1.0
 */
@Getter
@AllArgsConstructor
public enum ClientEnum {
    WEB("web", "web端"),
    CREATOR("creator", "创作者服务中心");
    private String type;
    private String name;

    public static boolean exitClientEnum(String type) {
        for (ClientEnum clientEnum : ClientEnum.values()) {
            if (clientEnum.getType().equals(type)) {
                return true;
            }
        }
        return false;
    }

    public static ClientEnum getClientEnum(String type) {
        if (StringUtils.isBlank(type)) {
            return null;
        }
        for (ClientEnum clientEnum : ClientEnum.values()) {
            if (clientEnum.getType().equals(type)) {
                return clientEnum;
            }
        }
        return null;
    }

    @Named("getClientName")
    public static String getClientName(String type) {
        if (StringUtils.isBlank(type)) {
            return ClientEnum.CREATOR.getName();
        }
        for (ClientEnum clientEnum : ClientEnum.values()) {
            if (clientEnum.getType().equals(type)) {
                return clientEnum.getName();
            }
        }
        return "";
    }
}
